//package com.opennetexam.manager.async;
//
//import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
//import org.springframework.scheduling.annotation.AsyncConfigurer;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
//
//import java.util.concurrent.Executor;
//import java.util.concurrent.ThreadPoolExecutor;
//import java.util.logging.Logger;
//
///**
// * @Description 异步线程池配置
// * @author 奶茶
// * Created by on 2018/9/19 16:17.
// */
//public class AsyncThreadPoolConfig implements AsyncConfigurer{
//
//    private static final Logger logger = Logger.getLogger(AsyncThreadPoolConfig.class.getName());
//
//    @Override
//    public Executor getAsyncExecutor() {
//        ThreadPoolTaskExecutor threadPool = new ThreadPoolTaskExecutor();
//        //核心线程数大小
//        threadPool.setCorePoolSize(5);
//        //最大线程数
//        threadPool.setMaxPoolSize(10);
//        //线程池缓冲队列大小
//        threadPool.setQueueCapacity(5);
//        //允许线程的空闲时间为60s，当超过了和弦线程数的线程会在60s后销毁
//        threadPool.setKeepAliveSeconds(60);
//        //当达到最大线程数后，调用所在的线程中执行；如果所在的线程已关闭则丢弃该任务
//        threadPool.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//        //优雅关机-等待所有线程执行完任务
//        threadPool.setWaitForTasksToCompleteOnShutdown(true);
//        //设置等待时间
//        threadPool.setAwaitTerminationSeconds(300);
//        //设置线程池线程名称前缀
//        threadPool.setThreadNamePrefix("CustomizeAsyncThreadPool_");
//        //初始化
//        threadPool.initialize();
//        logger.info("--------------------异步线程池初始化成功--------------------");
//        return threadPool;
//    }
//
//    @Override
//    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
//        return null;
//    }
//}
